<?php
/**
 * $Id: log.php 22 2011-09-20 10:52:20Z truongnhan0311 $
 */

class WrdLog
{
	function addEntry($status = 'DEBUG', $comment = '', $caller = null, $log = null, $debug_stack = 1) 
	{
		jimport('joomla.error.log');
				
		if (!$caller) {
			$db = debug_backtrace();
			$caller = (isset($db[$debug_stack]['class']) ? $db[$debug_stack]['class'].'::' : '') 
				. (isset($db[$debug_stack]['function']) ? $db[$debug_stack]['function'] : basename($db[$debug_stack]['file']));
		}

		if (!$log) $log = JLog::getInstance('eve.php');
		
		$log->addEntry(array(
			'status' => $status,
			'comment' => "$caller $comment"
		));
	}
	
	function debug($comment) 
	{
		return JomcastLog::addEntry('DEBUG', $comment, null, null, 2);
	}
	
	function error($comment) 
	{
		return JomcastLog::addEntry('ERROR', $comment, null, null, 2);
	}
	
	function info($comment) 
	{
		return JomcastLog::addEntry('INFO', $comment, null, null, 2);
	}
	
	function warn($comment) 
	{
		return JomcastLog::addEntry('WARN', $comment, null, null, 2);
	}
}

?>